﻿
@{
    ViewData["Title"] = "TaskErrorLog";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">

            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">任务名称：</label>
                        <div class="layui-input-inline mr0">
                            <input id="taskName" name="taskName" class="layui-input" type="text" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">执行时间：</label>
                        <div class="layui-input-inline mr0">
                            <input id="createTime" name="createTime" class="layui-input" readonly="readonly" type="text" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">组名称：</label>
                        <div class="layui-input-inline mr0">
                            <input id="groupName" name="groupName" class="layui-input" type="text" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">调用方式：</label>
                        <div class="layui-input-inline mr0">
                            <select name="method">
                                <option value="">全部</option>
                                <option value="get">Get</option>
                                <option value="post">Post</option>
                                <option value="put">Put</option>
                                <option value="delete">Delete</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn" lay-filter="formSubSearchTbBas" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button class="layui-btn icon-btn" lay-filter="DropCollection" lay-submit>
                            清空错误日志
                        </button>
                    </div>
                </div>
            </div>
            <table class="layui-table" id="tableTbBas" lay-filter="tableTbBas"></table>
        </div>
    </div>
</div>
<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table','laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var laydate = layui.laydate;
        form.render('select');
        // 渲染表格
        var insTb = table.render({
            elem: '#tableTbBas',
            url: '/api/Quartz/QueryTaskError',
            page: true,
            limit:30,
            cellMinWidth: 100,
            cols: [[
                { field: 'taskName', align: 'center', title: '任务名称' },
                { field: 'groupName', align: 'center', title: '组名称' },
                { field: 'taskUrl', align: 'center', title: '接口地址', width: '16%' },
                { field: 'method', align: 'center', title: '请求方式' },
                { field: 'requestBody', align: 'center', title: '请求参数', width: '10%' },
                { field: 'message', align: 'center', title: '错误信息' },
                { field: 'createTime', align: 'center', title: '执行时间' }
            ]]
        });

        //监听工具条
        table.on('tool(tableTbBas)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
        });

        // 搜索按钮点击事件
        form.on('submit(formSubSearchTbBas)', function (data) {
            insTb.reload({ where: data.field, page: { curr: 1 } }, 'data');
        });

        form.on('submit(DropCollection)', function () {
            layer.confirm('确认要清空错误日志吗?', { btn: ['确定', '取消'] }
                , function (index) {
                    $.ajax({
                        url:'/api/Quartz/DropTaskError',
                        type: 'delete',
                        contentType: "application/json",
                        dataType: "json",
                        success: function (res) {
                            if (res.success) {
                                layer.msg(
                                    res.message,
                                    { icon: 1, time: 2000 },
                                    function () {
                                        layer.close(index);
                                        insTb.reload({}, 'data');
                                    });
                            }
                        }
                    });
                });
        });

        //渲染时间控件
        laydate.render({
            elem: '#createTime',
            range: true
        });

    });
</script>

